/*
public class TreeNode {
      int val;
     TreeNode left;
     TreeNode right;
     TreeNode() {}
     TreeNode(int val) { this.val = val; }
     TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
          this.left = left;
         this.right = right;
      }
 }
*/

/*
class Solution {

    
    public TreeNode buildTree(int[] preorder, int[] inorder) {
        return buildTreeChild(preorder, inorder, 0, inorder.length-1);
    }

    private TreeNode buildTreeChild(int[] preorder, int[] inorder, int preIndex, int inbegin, int inend) {
        // 递归出口
        if(inbegin > inend) {
            return null;
        }
        //根 左 右
        TreeNode root = new TreeNode(preorder[preIndex]);
        int rootIndex = findIndex(inorder, inbegin, inend, preorder[preIndex]);
        preIndex++;
        

        root.left = buildTreeChild(preorder, inorder, preIndex, inbegin, rootIndex-1);
        root.right = buildTreeChild(preorder, inorder, preIndex, rootIndex+1, inend);

        return root;

    }

    private int findIndex(int[] inorder, int inbegin, int inend, int key) {
        for(int i = inbegin; i <= inend; i++) {
            if(inorder[i] == key) {
                return i;
            }
        }
        return -1;
    }
}*/
